<template>
  <a-tree
    class="dept-tree"
    :tree-data="treeData"
    @select="onSelect"/>
</template>

<script>
import { getAction } from '@/api/manage'
import { treeDataTranslate } from '@/utils/util'
export default {
  name: 'BizDeptShow',
  data () {
    return {
      treeData: []
    }
  },
  mounted () {
    this.initDeptTree()
  },
  methods: {
    initDeptTree () {
      getAction('/sys/dept/tree').then((res) => {
        const record = res.data
        // 转换格式
        this.treeData = treeDataTranslate(record, 'deptId', 'name')
      })
    },
    onSelect (selectedKeys, info) {
      console.log(selectedKeys)
      console.log(info)
    }
  }
}
</script>

<style scoped>
  .dept-tree{
    width: 200px;
  }

</style>
